<template>
	<view class="passenger-flow">
		<view class="box_9">
			<con-venues :itemChooselist='itemChooselist' :venuelist='venuelist' @confirm="confirm1"></con-venues>
			<view style="position: fixed;z-index: 999;width: 100%;top: 120rpx;">
				<view class="box_11">
					<view class="image-wrapper_7">
						<u-search v-model="searchKey3" placeholder="搜索" @search="onSearch3" :show-action="false"
							shape="square" />
					</view>
				</view>
			</view>
			<!-- 选择会员 -->
			<view class="" style="margin-top: 74rpx;">
				<scroll-view scroll-y class="listall" v-for="(item, index) in hylist" :key="index"
					@click="addstudent(item,index)">
					<v-gap />
					<view class="d-flex flex-column listsee">
						<view class="goods-item flex-align">
							<view class="image">
								<view
									style="width: 100%;height: 200rpx;background-color: #EDF5F5;display: flex;lex-direction: row; justify-content: center; align-items: center;">
									<image style="width: 100%;height: 200rpx;" :src="item.cover" mode="aspectFit">
									</image>
								</view>
							</view>
							<view class="detail">
								<view>
									<view class="title elipsis-1">{{ item.name }}</view>
									<view class="" style="display: flex; flex-direction: row; align-items: center;">
										<view class="tag flex-align">
											{{ item.course_name }}
										</view>
										<image style="width: 25rpx;height: 25rpx;"
											src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/f1c02d6507d5b869a8fa25b144993dc02a42e038.png"
											mode=""></image>
										<view style="color: #FE8C61;font-size: 24rpx;margin-left: 6rpx;">
											{{item.bishai}}
										</view>
									</view>
									<view
										style="font-size: 24rpx;color: #4E6EAF;margin-top: 20rpx;display: flex; flex-direction: row; ">
										<view class="tags flex-align">
											{{ item.train_enum_name }}
										</view>
										<view class="">
											{{item.area_name}}
										</view>
									</view>
									<view style="font-size: 24rpx;color: #4E6EAF;margin-top: 20rpx;">
										{{item.display_time}}
									</view>
								</view>
								<!-- <view class="flex-align">
									<view class="price">{{item.area_name}}</view>
								</view> -->
							</view>
						</view>
					</view>
				</scroll-view>

				<v-gap height="140rpx" color="#EDF5F5" />
			</view>
			<!-- <view class="d-flex flex-row justify-space-between justify-center align-center"
				style="position: fixed;bottom: 0;height: 120rpx;background-color: #fff;width: 100%;padding: 0 8%;z-index: 99;">
				<view class="" @click="plbatch" v-if="plshow"
					style="width: 45%;height: 80rpx;background: #ffffff;color: #ff4040;font-size: 24rpx;text-align: center;border-radius: 35rpx;line-height: 80rpx;border:#ff4040 1rpx solid">
					批量操作
				</view>
				<view class="" v-if="!plshow" @click="selectAllWeeks"
					style="width: 45%;height: 80rpx;background: #ffffff;color: #ff4040;font-size: 24rpx;text-align: center;border-radius: 35rpx;line-height: 80rpx;border:#ec6ff404052b 1rpx solid">
					全选
				</view>
				<view class="" @click="addstudent"
					style="width: 45%;height: 80rpx;background: linear-gradient(0deg, rgba(214, 53, 53, 0.9), rgba(255, 64, 64, 0.93), rgba(250, 142, 142, 0.93));color: #ffffff;font-size: 24rpx;text-align: center;border-radius: 35rpx;line-height: 80rpx;">
					添加学员
				</view>
			</view> -->

		</view>
	</view>
</template>

<script>
	const personal = require("@/api/personal/index.js");
	const venues = require("@/api/venues/venues.js");
	export default {
		data() {
			return {
				itemChooselist: {},
				venuelist: [],
				plshow: true,
				hylist: [
					{
						cover:'https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/67e6b341267a6.jpeg',
						name:'男子100比赛',
						course_name:'第三组',
						program_name:'',
						train_enum_name:'已开赛',
						area_name:'',
						less_stock:'',
						display_time:'2025-5.10-5.12',
						bishai:'比赛中'
					},
					{
						cover:'https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/67dfcaa84db07.jpeg',
						name:'女子200比赛',
						course_name:'第五组',
						program_name:'',
						train_enum_name:'待开赛',
						area_name:'',
						less_stock:'',
						display_time:'2025-5.12-5.14',
						bishai:'待比赛'
					}
				],
				listQuery: { //分页
					pageNo: 1,
					pageSize: 6,
				},
				totalPage: '', //几页
				searchKey3: '',
				venue_id:''
			}
		},
		onLoad(options) {
			var data = uni.getStorageSync("wqzdy");
			var items = JSON.parse(data)
			this.venuelist = items
			// 处理itemChooselist的逻辑
			if (this.venuelist.length > 0) {
				this.itemChooselist = this.venuelist[0]
				this.venue_id = this.venuelist[0].id
			} else {
				this.itemChooselist = {}; // 或者设置为其他默认值
			}
		},
		methods: {
			
			confirm1(data) {
				this.venue_id = data
			    console.log(data, 'data');
			    // 直接根据接收到的 id 在 venuelist 中查找对应的场馆对象
			    const selectedItem = this.venuelist.find(item => item.id === data);
			    if (selectedItem) {
			        // 将找到的场馆对象赋值给 itemChooselist
			        this.itemChooselist = selectedItem;
			    } else {
			        console.log(`未找到 id 为 ${data} 的场馆对象`);
			    }
			    console.log(this.itemChooselist, 'this.itemChooselist');
			},
			// 搜索事件处理
			onSearch3(value) {
				this.searchKey3 = value
			},

			async trainpro() {
				let that = this;
				if (this.listQuery.pageNo === 1) that.hylist = [];
				let params = {
					keyword: this.searchKey3,
					pageSize: this.listQuery.pageSize,
					page: this.listQuery.pageNo,
					venue_id: this.venue_id,
				}
				let res = await venues.trainpro(params)
				if (res.code === 1) {
					// this.hylist = res.data.list.data
					that.hylist = that.hylist.concat(res.data.list.data); //将数据拼接在一起
					that.totalPage = res.data.list.last_page
				}
			},
			// 下拉刷新
			onReachBottom() {
				if (this.totalPage <= this.listQuery.pageNo) {
					uni.showToast({
						title: '没有更多了',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				this.listQuery.pageNo += 1;
				this.trainpro()
			},
			addstudent(){
				uni.navigateTo({
					url:'./detail'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	// @import '../../static/css/member/member_index.scss';
	.passenger-flow {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background-color: #EDF5F5;
		padding: 0rpx 0 50rpx 0;
		position: relative;

		.u-search {
			margin-bottom: 20rpx;
		}

		.list-container {
			max-height: 300rpx;
			overflow-y: auto;
			box-shadow: 0 0 18rpx 8rpx hsla(0, 0%, 40%, .1);
			border-radius: 4rpx;
			padding: 10rpx;
			background-color: #fff;
			position: fixed;
			z-index: 999;
			top: 222rpx;
			left: 40rpx;
			width: 300rpx;
			font-size: 22rpx;

		}

		.list-container2 {
			max-height: 300rpx;
			overflow-y: auto;
			box-shadow: 0 0 18rpx 8rpx hsla(0, 0%, 40%, .1);
			border-radius: 4rpx;
			padding: 10rpx;
			background-color: #fff;
			position: fixed;
			z-index: 999;
			top: 222rpx;
			right: 40rpx;
			width: 300rpx;
			font-size: 28rpx;

		}

		.list {
			height: 100%;
		}

		.list-item {
			padding: 15rpx;
			// border-bottom: 1px solid #eee;
			cursor: pointer;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			font-size: 30rpx;
		}

		.card_jec {
			color: rgb(13, 132, 255);
		}

		.card_je {
			color: #000000;
		}

		.list-item:last-child {
			border-bottom: none;
		}

		.list-item:hover {
			background-color: #f5f5f5;
		}

		.selected-item {
			margin-top: 20rpx;
			font-size: 18rpx;
			color: #333;
		}

		.box_9 {
			width: 750rpx;
			height: 100%;
			// margin-bottom: 1rpx;
			display: flex;
			flex-direction: column;

			.tag-list {
				display: flex;
				margin-top: 30rpx;
				padding: 0 20rpx;

				/deep/ view {
					margin-left: 4rpx;
				}
			}

			.box_11 {
				width: 100%;
				height: 130rpx;
				display: flex;
				flex-direction: row;
				background: #ffffff;
				padding: 20rpx 0;
				position: absolute;
				justify-content: space-around;

				// .image-wrapper_7 {
				// 	width: 541rpx;
				// 	height: 60rpx;
				// 	flex-direction: row;
				// 	display: flex;
				// 	margin-top: 15rpx;
				// }
				.image-wrapper_7 {
					width: 90%;
					height: 62rpx;
					flex-direction: row;
					display: flex;
				}

				.label_list {
					display: flex;
					flex-direction: column;
					position: absolute;
					justify-content: center;
					/* 相对父元素水平居中 */
					align-items: center;
					/*  子元素相对父元素垂直居中 */
					right: 90rpx;
					width: 80rpx;
					top: 27rpx;

					.label_7 {
						width: 36rpx;
						height: 36rpx;
					}

					.label_77 {
						width: 60rpx;
						height: 36rpx;
						color: #333333;
						font-size: 26rpx;
						text-align: center;
					}
				}

				.label8_list {
					display: flex;
					flex-direction: column;
					position: absolute;
					justify-content: center;
					/* 相对父元素水平居中 */
					align-items: center;
					/*  子元素相对父元素垂直居中 */
					right: 20rpx;
					width: 80rpx;
					top: 27rpx;

					.label_8 {
						width: 36rpx;
						height: 36rpx;
					}

					.label_88 {
						width: 60rpx;
						height: 36rpx;
						color: #333333;
						font-size: 26rpx;
						text-align: center;
					}
				}
			}

			.all_whole {
				width: 100%;
				display: flex;
				flex-direction: column;
				background: #ffffff;

				.all_whole_be {
					display: flex;
					flex-direction: row;
					justify-content: space-around;

					.all_whole_or {
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;
						width: 20%;
						height: 150rpx;
						border-radius: 20rpx;
					}

					/* 使用类名来设置背景色 */
					.bg-color-all {
						background: linear-gradient(0deg, rgb(173, 201, 246) 0%, rgb(231, 239, 255) 100%);
					}

					.bg-color-reading {
						background: linear-gradient(0deg, #ccffcc 0%, #edffea 100%);
					}

					.bg-color-graduated {
						background: linear-gradient(0deg, #fbdafd 0%, #fdeffd 100%);
					}

					.bg-color-potential {
						background: linear-gradient(0deg, #f9ffcf 0%, #fdffe9 100%);
					}

					.wz-color-all1 {
						font-size: 24rpx;
					}

					.wz-color-all2 {
						color: #3479da;
						font-weight: 600;
						font-size: 26;
					}

					.wz-color-reading2 {
						color: #67ca55;
						font-weight: 600;
						font-size: 26;
					}

					.wz-color-graduated2 {
						color: #a672c6;
						font-weight: 600;
						font-size: 26;
					}

					.wz-color-potential2 {
						color: #b39b64;
						font-weight: 600;
						font-size: 26;
					}
				}

				.all_potent {
					display: flex;
					flex-direction: row;
					justify-content: space-around;
					color: #c2c2c2;
					font-size: 22rpx;
					height: 80rpx;
					width: 100%;
					justify-content: space-between;
					align-items: center;
					padding: 0 20rpx;

					.all_shuju1 {}

					.all_shuju2 {
						display: flex;
						flex-direction: row;
						justify-content: center;
						align-items: center;

						.all_shuju2_img {
							width: 20rpx;
							height: 20rpx;
							margin-right: 10rpx;
						}
					}
				}

				.alls_potent {
					display: flex;
					flex-direction: row;
					justify-content: space-around;
					height: 80rpx;
					width: 100%;
					justify-content: space-between;
					align-items: center;
					padding: 0 20rpx;

					.alls_shuju1 {
						font-size: 28rpx;
					}

					.alls_shuju2 {
						display: flex;
						flex-direction: row;
						justify-content: center;
						align-items: center;

						.alls_shuju2_img {
							width: 20rpx;
							height: 20rpx;
						}
					}
				}
			}

			.listall {
				.listsee {
					background-color: #fff;
					padding: 30rpx;
					border-radius: 10rpx;
					width: 94%;
					margin-left: 3%;
					border: 2rpx #fff solid;

					.goods-item {
						height: 200rpx;

						.image {
							width: 200rpx;
							height: 100%;
							border-radius: 7rpx;
							// overflow: hidden;
							position: relative;

							/deep/ .u-transition {
								width: 100%;
								height: 100%;
							}

							.image-info {
								position: absolute;
								bottom: 0;
								width: 100%;
								left: 0;
								font-size: 24rpx;
								text-align: center;
								color: white;
								padding: 10rpx 0;
								background-color: rgba(0, 0, 0, 0.5);
							}
						}

						.detail {
							flex: 1;
							width: 0;
							height: 100%;
							display: flex;
							flex-direction: column;
							margin-left: 20rpx;
							justify-content: space-between;

							.title {
								font-size: 28rpx;
								margin-bottom: 10rpx;
								width: 100%;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;
							}

							.tag {
								font-size: 22rpx;
								color: #2F75FA;
								background-color: #d5e3fe;
								border-radius: 8rpx;
								padding: 5rpx 10rpx;
								margin-right: 20rpx;
							}

							.tags {
								font-size: 22rpx;
								color: #2F75FA;
								background-color: #d5e3fe;
								border-radius: 8rpx;
								padding: 5rpx 10rpx;
								margin-right: 20rpx;
							}

							.detail-2 {
								color: #a3a3a3;
								font-size: 23rpx;

								image {
									width: 25rpx;
									height: 25rpx;
									margin-right: 10rpx;
								}
							}

							.price {
								color: #ff6a42;

								text {
									font-weight: 700;
									font-size: 37rpx;
								}
							}

							.info {
								color: #a3a3a3;
								font-size: 23rpx;
								margin-left: 15rpx;
								transform: translateY(4rpx);
							}
						}
					}
				}

				.active1 {
					border: 2rpx #0000ff solid;
				}
			}

		}
	}
</style>